package com.wmuj.controller;

import com.wmuj.pojo.Emp;
import com.wmuj.pojo.Login;
import com.wmuj.pojo.Result;
import com.wmuj.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class LoginController {
  /** 登录 */
  @Autowired private EmpService empService;

  @PostMapping("/login")
  public Result login(@RequestBody Emp emp) {
    log.info("登录中.........,{}", emp);
    Login loginInfo = empService.login(emp);
    if (loginInfo != null) {
      return Result.success(loginInfo);
    }
    return Result.error("用户名或密码错误~");
  }
}
